from time import sleep

import greenlet as greenlet


def a():
    for i in range(3):
        print('-------a-----{}'.format(i))
        gb.switch()
        sleep(0.2)


def b():
    for i in range(3):
        print('-------b-----{}'.format(i))
        gc.switch()
        sleep(0.2)


def c():
    for i in range(3):
        print('-------c-----{}'.format(i))
        ga.switch()
        sleep(0.2)


if __name__ == '__main__':
    ga = greenlet(a)
    gb = greenlet(b)
    gc = greenlet(c)

    ga.switch()
'''
-------a-----0
-------b-----0
-------c-----0
-------a-----1
-------b-----1
-------c-----1
'''
